﻿package com.PlantVsZombies.Zombies;

import com.PlantVsZombies.common.Zombie;
import com.PlantVsZombies.util.ImageUtil;

public class Zombie_Normal extends Zombie {

	public Zombie_Normal(int row, int col) {
		super(row, col);
		this.setImage(ImageUtil.zombie);
		this.setLife(9);
		this.setSpeed(1);
	}

	@Override
	public int doRun() {
		if(this.getLife() == 3 && this.hasHead){
			new Thread(new LostHead(this.getRow(), this.getCol())).start();
			this.hasHead = false;
		}
		switch (this.getLife()) {
		case 0:
			this.setImage(ImageUtil.LoadImage(ImageUtil.zombieDie));
			this.setSpeed(0);
			new diedThread().start();
			return 0;
		case 1:
		case 2:
		case 3:
			if (!this.isAttack())
				this.setImage(ImageUtil.zombieLostHead);
			else
				this.setImage(ImageUtil.zombieAttack_LostHead);
			break;
		case 4:
		case 5:
		case 6:
		case 7:
		case 8:
		case 9:
			if (!this.isAttack())
				this.setImage(ImageUtil.zombie2);
			else
				this.setImage(ImageUtil.zombieAttack);
			break;
		case -10:
			this.setImage(ImageUtil.LoadImage(ImageUtil.BoomDie1));
			new diedThread().start();
			return 0;
		default:
			break;
		}

		this.move();
		try {
			Thread.sleep(100);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return 1;
	}

}
